import initApi from '@/apis/init.js';

// 防抖函数
export function debounce (fn, delay) {
    let timer
    return function () {
      if (timer) {
        clearTimeout(timer)
      }
      timer = setTimeout(() => {
        fn()
      }, delay)
    }
  }
	
export	function customDebounce(func, delay) {
	  let timer = null;
	  let isFirstClick = true;
	  return function() {
	    if (isFirstClick) {
	      func.apply(this, arguments);
	      isFirstClick = false;
	    } else {
	      clearTimeout(timer);
	      timer = setTimeout(() => {
	        func.apply(this, arguments);
	      }, delay);
	    }
	  };
	}


// 统计
export function getProductNum(a, p, uuids) {
	if (a && p && uuids) {
		const arr = {
			channelCode: a,
			productCode: p,
			uuid: uuids
		};
		initApi.indicatorsRecordPageViewsPost(arr);
	}
}